Skip to content

ctags: filterSketchSource: enlarge buffer size to handle long lines #2935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2025

Conversation

facchinm
Copy link
Member

@facchinm facchinm commented Jun 16, 2025

Fixes arduino/ArduinoCore-zephyr#140

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

When parsing the preprocessed file, only the lines relevant for the sketch are preserved.
However, golang's scanner fails if a line is too long for its buffer.
Overcome the issue by adding a 1MB buffer (extremely conservative) and a non-fatal error message in case it's still not enough.

What is the current behavior?

Compiling any sketch from https://github.com/arduino/ArduinoCore-zephyr fails to create prototypes due to analogPins macro, which expands into a ~90K characters line

What is the new behavior?

The prototypes are created correctly

Does this PR introduce a breaking change, and is titled accordingly?

No breaking change

Other information

@facchinm facchinm requested a review from cmaglie June 16, 2025 09:45
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: build-process Related to the sketch build process labels Jun 16, 2025
@cmaglie
Copy link
Member

cmaglie commented Jun 26, 2025

Can you provide an example of a preprocessed source to make a unit test?

@cmaglie
Copy link
Member

cmaglie commented Jun 26, 2025

I've tested the example in arduino/ArduinoCore-zephyr#140 and the patch doesn't seem to solve the issue 🤔

~/Arduino/Test$ arduino-cli compile -b arduino:zephyr:giga --build-path build 
/home/cmaglie/Arduino/Test/Test.ino: In function 'void setup()':
/home/cmaglie/Arduino/Test/Test.ino:6:3: error: 'wait_for_input' was not declared in this scope
    6 |   wait_for_input();
      |   ^~~~~~~~~~~~~~

Piattaforma utilizzata Versione Percorso
arduino:zephyr         0.3.1    /home/cmaglie/.arduino15/packages/arduino/hardware/zephyr/0.3.1
Si è verificato un errore durante la compilazione: exit status 1

@cmaglie
Copy link
Member

cmaglie commented Jun 26, 2025

Ok, never mind, my mistake. PEBKAC. The patch works.

@cmaglie cmaglie force-pushed the scanner_line_too_long branch from 2ba1862 to f6153ba Compare June 26, 2025 15:34
@cmaglie cmaglie self-assigned this Jun 26, 2025
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 58.33333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 67.81%. Comparing base (241e7d4) to head (f6153ba).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...nal/arduino/builder/internal/preprocessor/ctags.go 58.33% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2935      +/-   ##
==========================================
- Coverage   67.81%   67.81%   -0.01%     
==========================================
  Files         238      238              
  Lines       22450    22460      +10     
==========================================
+ Hits        15225    15231       +6     
- Misses       6022     6025       +3     
- Partials     1203     1204       +1     
Flag Coverage Δ
unit 67.81% <58.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cmaglie cmaglie merged commit 4891ded into arduino:master Jun 26, 2025
101 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zephyr Arduino Builds are not creating the function prototypes, like other builds...
4 participants